<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzb.erp.api.pc.creditMall.mapper.CreditMallMapper">
    <sql id="Base_Column_List">
        id,material_id,name,
        sale_num,view_num,content,
        creator,editor,add_time,
        edit_time,deleted
    </sql>
    <select id="getList" resultType="com.hzb.erp.api.pc.creditMall.pojo.CreditMallVO">
        select t1.*,
        t2.cover cover, t2.storage, t3.name school_name
        from credit_mall t1
        left join material t2 on t2.id = t1.material_id
        left join org t3 on t3.id = t1.school_id
        <where>
            t1.deleted = 0
            <if test="param.name != null and param.name != ''">
                AND t1.name like concat('%', #{param.name}, '%')
            </if>
            <if test="param.categoryId != null">
                AND t1.category_id = #{param.categoryId}
            </if>
            <if test="param.canExchange != null and param.canExchange">
                AND t1.state = 1 And t2.state = 1  AND t2.storage > 0
            </if>
            <if test="param.state != null">
                AND t1.state = #{param.state}
            </if>
        </where>
        order by t1.id desc
    </select>
    <select id="getInfo" resultType="com.hzb.erp.api.pc.creditMall.pojo.CreditMallVO">
        select t1.*
        from material t1
        where t1.id = #{id}
    </select>
</mapper>
